// 定义点菜订单和详单数据结构和功能
#ifndef DISH_ORDER_MANAGE_H
#define DISH_ORDER_MANAGE_H
#include <conio.h>
#include "LoginManage.h"
#include "../util/InputFormat.h"
#include "../util/FileManage.h"
#include "../util/LinkedList.h"
#include "TableManage.h"
#include "DishManage.h"

// 订单
struct DishOrder
{
	char orderNo[15];	  // 订单号
	char orderStaff[10];  // 结账员工
	char orderTableNo[6]; // 餐桌号
	int orderTotalMoney;  // 总金额
	int orderAmount;	  // 总份数
};

// 详单
struct DetailOrder
{
	char detailOrderNo[15]; // 详单号
	struct Menu detailMenu; // 某道菜
	int detailOrderAmount;	// 某道菜的份数
};

// 订单数据初始化
// 返回初始化后的订单链表指针
struct DishOrder *DishOrderInit(char orderTableNo[]);

// 详单数据初始化
// 返回初始化的详单链表指针
struct DetailOrder *DetailOrderInit(struct DishOrder *dishOrder, struct Menu *menu, int dishAmount);

// 添加菜品
// orderCount: 菜谱链表的个数
// dishOrder: 订单数据指针
// detailOrderPointer: 详单链表头指针
// dishOrderPointer: 订单链表头指针
// menuPointer: 菜谱链表头指针
// orderSavePath: 详单存放路径
void DishOrderAdd(int orderCount, struct DishOrder *dishOrder, ListPointer detailOrderPointer, ListPointer dishOrderPointer, ListPointer menuPointer, char orderSavePath[]);

// 添加菜品
// orderCount: 菜谱链表的个数
// dishOrder: 订单数据指针
// detailOrderPointer: 详单链表头指针
// menuPointer: 菜谱链表头指针
// dishOrderPointer: 订单链表头指针
// orderSavePath: 详单存放路径
void DishOrderDelete(int orderCount, struct DishOrder *dishOrder, ListPointer detailOrderPointer,
					 ListPointer menuPointer, ListPointer dishOrderPointer, char orderSavePath[]);

// 订单汇总分析： 总金额、总份数
// dishOrder: 订单链表指针
// detailOrderPointer: 详单链表头指针
void DishOrderStatist(struct DishOrder *dishOrder, ListPointer detailOrderPointer);

// 订单打印
// menuPointer: 菜单头指针
// detailOrderPointer: 详单头指针
// dishOrder: 订单数据指针
void DishOrderPrint(ListPointer menuPointer, ListPointer detailOrderPointer, struct DishOrder *dishOrder);

// 订单号生成函数, 返回订单号
// orderNumber: 订单号
// tableNumber: 餐桌号
long OrderNoGenerate(char orderNumber[], char tableNumber[]);

// 输入日期格式化控制函数
void OrderDateInputFormat(long *startDate, long *endDate){}

// 日期转化为字符串
void Date2String(char dateString[], int date, int dateLength);

// 未购订单查询
void DishOrderUnbuySearch(ListPointer dishOrderPointer);

// 已购订单查询
void DishOrderBuySearch();

// 详单打印
// detailOrderPointer: 详单头指针
// dishOrderPointer: 订单数据指针
void DetailOrderPrint(ListPointer detailOrderPointer, struct DishOrder *dishOrderPointer);

#endif
